package qqtalk.gonggong;

import javax.swing.*;
import javax.swing.text.JTextComponent;
import java.io.OutputStream;
import java.io.PrintStream;

public class NetPrintStream extends PrintStream {
    public JTextComponent component;
    public StringBuffer sb=new StringBuffer();
    public NetPrintStream(OutputStream stream, JTextComponent component){
        super(stream);
        this.component=component;
    }

    public void write(byte[] by,int off,int len){
        final String meaasge=new String(by,off,len);
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                sb.append(meaasge);
                component.setText(sb.toString());
            }
        });

    }

}
